<template>
  <div class="list-table">
    <div class="area-header" style="margin-top: 15px;" />
    <el-form ref="queryForm" :model="queryParams" :inline="true" style="padding: 1% 1%;">
      <el-form-item :label="$t('名称')" prop="nickName">
        <el-input
          v-model="queryParams.nickName"
          :placeholder="$t('名称')"
          clearable
          @keyup.enter.native="queryHandle"
        />
      </el-form-item>
      <el-form-item :label="$t('手机号码')" prop="phone">
        <el-input
          v-model="queryParams.phone"
          :placeholder="$t('手机号码')"
          clearable
          @keyup.enter.native="queryHandle"
        />
      </el-form-item>
      <el-form-item :label="$t('手机号码')" prop="phone">
        <el-input
          v-model="queryParams.phone"
          :placeholder="$t('手机号码')"
          clearable
          @keyup.enter.native="queryHandle"
        />
      </el-form-item>
      <el-form-item :label="$t('人员类型')" prop="interviewTime">
        <el-select v-model="queryParams.personType" clearable :placeholder="$t('人员类型')">
          <el-option :label="$t('内部访问')" :value="$t('内部访问')" />
          <el-option :label="$t('外部访问')" :value="$t('外部访问')" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="queryHandle">{{ $t('搜索') }}</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('重置') }}</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="sysSharingAccessRecordList" border style="margin-top: 50px;">
      <el-table-column :label="$t('序号')" type="index" align="center" show-overflow-tooltip width="50">
        <template slot-scope="scope">
          {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('名称')" align="center" prop="nickName" />
      <el-table-column :label="$t('手机号码')" align="center" prop="phone" />
      <el-table-column :label="$t('人员类型')" align="center" prop="personType" />
      <el-table-column :label="$t('访问时间')" align="center" prop="interviewTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.interviewTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList()"
    />
  </div>
</template>

<script>
import { listSysSharingAccessRecord } from '@/api/file/share/sysShareFiles.js'
export default {
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 文件分享访问记录表格数据
      sysSharingAccessRecordList: [],
      // 弹出层标题
      title: '文件分享访问记录',
      // 是否显示弹出层
      formOpen: false,
      // 查询参数
      queryParams: {
        nickName: undefined,
        personType: undefined,
        phone: undefined,
        interviewTime: undefined,
        parentId: undefined,
        pageNum: 1,
        pageSize: 10
      },
      // 日期范围
      dateRange: [],
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      shareFileId: undefined
    }
  },
  created() {
  },
  methods: {
    /** 查询文件分享访问记录列表 */
    getList() {
      this.loading = true
      this.queryParams.parentId = this.shareFileId
      listSysSharingAccessRecord(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        this.sysSharingAccessRecordList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        userId: undefined,
        nickName: undefined,
        phone: undefined,
        viewType: undefined,
        personType: undefined,
        interviewTime: undefined
      }
      this.resetForm('form')
    },
    /** 搜索按钮操作 */
    queryHandle() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = []
      this.queryParams.personType = undefined
      this.resetForm('queryForm')
      this.queryHandle()
    }
  }
}
</script>
